<? if( $_SESSION[ "JC_account_authority" ] ) { ?>

	<? $JC_select = JC_select( ); ?>

	<table>

		<tr>

			<? if( $_REQUEST[ "JC_table" ] == "file" ) { ?>

				<th>File</th>

			<? } ?>

			<? foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) { ?>

				<? if( $key == "comment"															) continue; ?>
				<? if( $_SESSION[ "JC_filter_omit_" . $_REQUEST[ "JC_table" ] . "." . $key ]	) continue; ?>

				<th><?= JC_TH( $key ) ?></th>

			<? } ?>

			<? if( JC_authority( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ "key" ][ "AIUD" ] ) ) { ?>

				<th>Update</th>
				<th>Delete</th>

			<? } ?>

		</tr>



		<? if( $JC_select ) while( $record = $JC_select -> fetch_array( ) ) { ?>

			<tr>

				<? if( $_REQUEST[ "JC_table" ] == "file" ) { ?>

					<td>

						<? if( strpos( $record[ "type" ], "image" ) !== false ) { $host = JC_TA( $record[ "host" ], null, "\r\n" ); ?>

							<a href="<?= $JC_host[ $host[ 0 ] ][ "folder" ] . "/" . $record[ "name" ] ?>" target="JC_file"><img src="<?= $JC_host[ $host[ 0 ] ][ "folder" ] . "/" . $record[ "name" ] ?>" style="width: 60px;" /></a>

						<? } ?>

					</td>

				<? } ?>

				<form id="JC_update_form_<?= $record[ "key" ] ?>" target="JC_asynchronous" method="post">

					<input type="hidden" name="JC_query"			value="update"								/>
					<input type="hidden" name="JC_table"			value="<?= $_REQUEST[ "JC_table" ] ?>"	/>
					<input type="hidden" name="JC_update_key"	value="<?= $record[ "key" ] ?>"				/>

					<? foreach( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ] as $key => $value ) { ?>

						<? if( $key == "comment"															) continue; ?>
						<? if( $_SESSION[ "JC_filter_omit_" . $_REQUEST[ "JC_table" ] . "." . $key ]	) continue; ?>



						<? if( $value[ "option" ] ) { // Option ?>

							<td>
								<select
									id		= "JC_select_<?= $key ?>_<?= $record[ "key" ] ?>"
									name	= "JC_update_<?= $key ?><?= $value[ "multiple" ] ? "[ ]" : "" ?>"
									title	= "<?= $record[ $key ] ? $record[ $key ] : $value[ "type" ] ?>"
									onfocus	= "document.getElementById( 'JC_update_<?= $record[ "key" ] ?>' ).innerHTML = 'Update';"
									onblur	= "if( this.value ) { this.title = this.value; } else { this.title = '<?= $value[ "type" ] ?>'; }"
									<?= $value[ "multiple" ] ? "size='2' multiple" : "" ?>
								>

									<? if( $value[ "null" ] ) { ?><option></option><? } ?>

									<? foreach( explode( ',', $value[ "option" ] ) as $option ) { ?>

										<option value="<?= trim( $option ) ?>" <?= $record[ $key ] && in_array( trim( $option ), JC_TA( $record[ $key ], null, "\r\n" ) ) ? "selected" : "" ?>><?= trim( $option ) ?></option>

									<? } ?>

								</select>
							</td>

							<? continue; ?>

						<? } ?>



						<? if( strpos( $value[ "type" ], "int" ) !== false || strpos( $value[ "type" ], "float" ) !== false ) { // Integer & Float ?>

							<? if( JC_authority( $value[ "AIUD" ] ) && $key != "key" ) { ?>

								<td>
									<input
										id		= "JC_select_<?= $key ?>_<?= $record[ "key" ] ?>"
										name	= "JC_update_<?= $key ?>"
										value	= "<?= $record[ $key ] ?>"
										title	= "<?= $record[ $key ] ? $record[ $key ] : $value[ "type" ] ?>"
										size	= "<?= $value[ "size" ] ? $value[ "size" ] : 6 ?>"
										class	= "right"
										onfocus	= "document.getElementById( 'JC_update_<?= $record[ "key" ] ?>' ).innerHTML = 'Update';"
										onblur	= "if( this.value ) { this.title = this.value; } else { this.title = '<?= $value[ "type" ] ?>'; }"
									/>
								</td>

							<? } else { ?>

								<td class="right form"><?= number_format( $record[ $key ] ) ?></td>

							<? } ?>

						<? } ?>



						<? if( strpos( $value[ "type" ], "char" ) !== false || strpos( $value[ "type" ], "date" ) !== false ) { // Character & Date ?>

							<? if( JC_authority( $value[ "AIUD" ] ) && $key != "insert" && $key != "update" ) { ?>

								<td>
									<input
										id		= "JC_select_<?= $key ?>_<?= $record[ "key" ] ?>"
										name	= "JC_update_<?= $key ?>"
										value	= "<?= $record[ $key ] ?>"
										title	= "<?= $record[ $key ] ? $record[ $key ] : $value[ "type" ] ?>"
										size	= "<?= $value[ "size" ] ? $value[ "size" ] : 12 ?>"
										onfocus	= "document.getElementById( 'JC_update_<?= $record[ "key" ] ?>' ).innerHTML = 'Update';"
										onblur	= "if( this.value ) { this.title = this.value; } else { this.title = '<?= $value[ "type" ] ?>'; }"
									/></td>

							<? } else { ?>

								<td class="form"><?= $record[ $key ] ?></td>

							<? } ?>

						<? } ?>



						<? if( $value[ "type" ] == "text" ) { // Text ?>

							<td>
								<textarea
									name	= "JC_update_<?= $key ?>"
									title	= "<?= $record[ $key ] ? $record[ $key ] : $value[ "type" ] ?>"
									cols	= "<?= $value[ "size" ] ? $value[ "size" ] : ( $value[ "FKF" ] ? "6" : "12" ) ?>"
									rows	= "1"

									<? if( JC_authority( $value[ "AIUD" ] ) && $key != "log" ) { ?>

										id		= "JC_select_<?= $key ?>_<?= $record[ "key" ] ?>"
										onfocus	= "document.getElementById( 'JC_update_<?= $record[ "key" ] ?>' ).innerHTML = 'Update';"
										onblur	= "if( this.value ) { this.title = this.value; } else { this.title = '<?= $value[ "type" ] ?>'; }"

									<? } else { ?>

										readonly

									<? } ?>

								><?= $record[ $key ] ?></textarea>
							</td>

						<? } ?>



						<? // Select ?>

						<? // File ?>



						<? if( strpos( $key, " FKF" ) ) { // Foreigh Key Field ?>

							<td>
								<textarea
									name	= "JC_update_<?= $key ?>"
									title	= "<?= $record[ $key ] ? $record[ $key ] : $value[ "type" ] ?>"
									cols	= "<?= $value[ "size" ] ? $value[ "size" ] : "12" ?>"
									rows	= "1"
									readonly
								><?= $record[ $key ] ?></textarea>
							</td>

						<? } ?>



					<? } ?>



					<? if( JC_authority( $_SESSION[ "JC_scheme" ][ $_REQUEST[ "JC_table" ] ][ "key" ][ "AIUD" ] ) ) { ?>

						<td>
							<a
								href	= "#this"
								id		= "JC_update_<?= $record[ "key" ] ?>"
								onclick	= "document.getElementById( 'JC_update_form_<?= $record[ "key" ] ?>' ).submit( );"
								class	= "form"
							/></a>
						</td>
						<td>
							<a
								href	= "#this"
								id		= "JC_delete_<?= $record[ "key" ] ?>"
								onclick	= "document.getElementById( 'JC_asynchronous' ).src='?JC_table=<?= $_REQUEST[ "JC_table" ] ?>&JC_query=delete&JC_delete_key=<?= $record[ "key" ] ?>';"
								class	= "form"
							/>Delete</a>
						</td>

					<? } ?>

				</form>

			<tr>

		<? } ?>

	</table><hr />

<? } ?>
